import Vue from 'vue'
//进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'

//vue电商后台管理系统 服务器基准地址
const http = axios.create({ baseURL: 'http://127.0.0.1:8888/api/private/v1/' })
Vue.prototype.$http = http

//请求拦截器 获取token值
http.interceptors.request.use(function(config) {
    NProgress.start()
    config.headers.Authorization = window.sessionStorage.getItem("token")
    return config;
});
//响应拦截器
http.interceptors.response.use(function(config) {
    NProgress.done()
    return config;
})

export default http